﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zeus.Thunder.Core;
using CsharpTrainer.Model.Entities;
using System.Runtime.Serialization;
using System.Xml;

namespace SharpTrainer.Serialization
{
    class XmlSettingTest : ITestCase
    {
        public void Run()
        {
            PersonList persons = new PersonList
            {
                new Person { Name = "Kelvin", Age = 30 },
                new Person { Name = "Peter", Age = 20 },
                new Person { Name = "David", Age = 35 }
            };
            var ds = new DataContractSerializer(typeof(PersonList));

            XmlWriterSettings settings = new XmlWriterSettings() { Indent = true };
            using (XmlWriter w = XmlWriter.Create("person_format.xml", settings))
                ds.WriteObject(w, persons);

            System.Diagnostics.Process.Start("person_format.xml");

            Console.WriteLine("Serialization Successful!");
        }
    }
}
